round
对浮点数进行四舍五入
round()
函数对浮点数进行四舍五入。
<?php echo(round(0.60)); echo(round(0.50)); echo(round(0.49)); echo(round(-4.40)); echo(round(-4.60)); ?>
亲自试一试
round(x,prec)
参数 | 描述 |
---|---|
x | 可选。规定要舍入的数字。 |
prec | 可选。规定小数点后的位数。 |
返回将 x 根据指定精度 prec (十进制小数点后数字的数目)进行四舍五入的结果。prec 也可以是负数或零(默认值)。